Test-Series - programming logic

Test Number 1/15

Q: Which of the following uses structure?
A. Linked Lists
B. Array of structures
C. Binary Tree
D. All of these
Solution: The structure is a user-defined data type in C language which allows us to combine data of different types together. Structure helps to construct a complex data type that is more meaningful. It is somewhat similar to an Array, but an array holds data of similar type only. But the structure, on the other hand, can store data of any type, which is practical more useful.

The correct answer is:
All of these
Q: How many specifiers are present in access specifiers in class? (c++)
A. 4
B. 1
C. 3
D. 2
Solution: In C++, there are three access specifiers:
public - members are accessible from outside the class.
private - members cannot be accessed from outside the class.
protected - members cannot be accessed from outside the class, however, they can be accessed in inherited classes.

The correct answer is:3
Q: John wants to go to different locations of the city in which he is. He has listed all of them down. However, he wants to visit one location before visiting some other location What application of graphs he uses to determine that location?
A. Dijkstra’s
B. DFS
C. Topological Sorting
D. BFS
Solution: Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u v, vertex u comes before v in the ordering.

The correct answer is: Topological Sorting
Q: What is an array?
A. An array is a series of element
B. None of the mentioned
C. An array is a series of elements of the same type in contiguous memory locations.
D. An array is a series of elements of the same type placed in noncontiguous memory locations
Solution: An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string. Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.

The correct answer is:
An array is a series of elements of the same type in contiguous memory locations.
Q: An expression involving byte, int, and literal numbers is promoted to which of these?
A. long
B. float
C. byte
D. int
Solution: It will be converted to int before any calculation is done.

The correct answer is:
int
Q: A pointer variable can be
A. Passed to a function as argument.
B. None of these
C. Assigned an integer value.
D. Changed within function.
Solution: A pointer is a variable that stores the address of another variable.  For example, an integer variable stores an integer value, however, an integer pointer holds the address of an integer variable.

The correct answer is:
Passed to a function as argument.
Q: What is the output of this program?

#include < stdio.h >
#include < string.h >
#include < stdlib.h >

void myfunc(char** param) {
++param;}

int main(){
char* string = (char*)malloc(64);
strcpy(string. "hello_world");
myfunc(&string);
myfunc(&string);
printf("&s
", string);
//ignore memory leak for sake of quiz
return 0;
A. lo_World
B. hello_World
C. llo_World
D. ello_World
Solution: The correct answer is:
hello_World
Q: What is the output of this program?

#include < stdio.h >
using namespace std;
int main()
{
char str[5] = "ABC";
cout << str[3];
cout <
A. ABCD
B. None of the mentioned
C. ABC
D. AB
Solution: The correct answer is:
ABC
Q: What is the output of this program?

#include < stdio.h >
void main()
{
int k = 5;
int *p =&k;
int **m = &p;
printf("&d&d&d
", k, *p, **p);
}
A. 5 junk junk
B. 5 5 5
C. 5 5 junk
D. Compile time error
Solution: It is a Compile time error.

Compile-Time Errors: Errors that occur when you violate the rules of writing syntax are known as Compile-Time errors. 
The correct answer is:
Compile time error

You Have Score    /9